{extend name="public/base"/}
{block name="body"}
<title>订单列表</title>
<style type="text/css">
	.pagelist ul li{display:inline-block;width:auto;height:20px;text-align:center;padding:0 5px;}
	.pagelist ul li a{width:auto;height:20px;}
	.pagelist ul li.active{background-color:#ccc !important;color:#fff;}
	.selecttmd,.pay_style{width:80px;height:30px;border:solid 1px #ddd;}
</style>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 订单管理 <span class="c-gray en">&gt;</span> 订单列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<form class="text-c">
		状态： 
		<select id="selecttmd" class="selecttmd" name="state" size="1">
				<option value="0" {if $state==0}selected{/if}>全部</option>
				<option value="1" {if $state==1}selected{/if}>待付款</option>
				<option value="2" {if $state==2}selected{/if}>待发货</option>
				<option value="3" {if $state==3}selected{/if}>待收货</option>
				<option value="4" {if $state==4}selected{/if}>已完成(待评价)</option>
				<option value="5" {if $state==5}selected{/if}>退款/售后</option>
				<option value="6" {if $state==6}selected{/if}>取消付款</option>
		</select>
		支付方式： 
		<select id="pay_style" class="pay_style" name="pay_style" size="1">
				<option value="0" {if $pay_style==0}selected{/if}>全部</option>
				<option value="1" {if $pay_style==1}selected{/if}>支付宝</option>
				<option value="2" {if $pay_style==2}selected{/if}>微信</option>
		</select>
		日期范围：
		<input name="fromtime" type="text" {literal} onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })" {/literal} id="datemin" class="input-text Wdate" style="width:120px;" value="{$fromtime}">
		-
		<input name="totime" type="text" {literal} onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })" {/literal} id="datemax" class="input-text Wdate" style="width:120px;" value="{$totime}">
		
		<input type="text" class="input-text" style="width:300px;font-size:12px;" placeholder="输入订单号/姓名/电话/产品" id="keyword" name="keyword" value="{$keyword}">
		<button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
	</form>
  	<div class="cl pd-5 bg-1 bk-gray mt-20">
		<a class="btn btn-success radius" href="{:url('export_order')}">导出</a>
	</div>
	<table class="table table-border table-bordered table-bg mt-20">
		<thead>
			<tr>
				<th scope="col" colspan="15">订单列表：<span>实付金额(待发、待收、已完成)：<strong>{$pay_fees}</strong>元(<i style="text-decoration: line-through;">{$f_pay_fees}元</i>)</span><span class="r">共有数据：<strong>{$count}</strong> 条</span></th>
			</tr>
			<tr class="text-c">
				<th width="40">ID</th>
				<th width="120">订单号</th>
				<th width="120">产品</th>
				<th width="50">收货人姓名</th>
				<th width="80">收货人手机号</th>
				<th width="40">购买量</th>
				<th width="50">单价</th>
				<th width="50">支付金额</th>
				<th width="50">支付方式</th>
				<th width="30">发票</th>
				<th width="40">状态</th>
				<th width="100">时间</th>
				<th width="50">操作</th>
			</tr>
		</thead>
		<tbody>
			{foreach $list as $key=>$value }
			<tr class="text-c" id="val_{$value.id}">
				<td>{$value.id}</td>
				<td><a style="color:#6db3e3;" onclick="order_detail('详情','{:url('order_detail')}?id={$value.id}',{$value.id},'800','500')">{$value.ordernosub}</a></td>
				<td>{$value.title}</td>
				<td>{$value.name}</td>
				<td>{$value.phone}</td>
				<td>{$value.buy_num}</td>
				<td>{$value.price}</td>
				<td>{$value.pay_fee}</td>
				<td class="td-status">
					{if $value.pay_style==1}
					支付宝
					{elseif $value.pay_style==2}
					微信
					{/if}
				</td>
				<td class="td-status">
					{if $value.is_invoice==1}
					否
					{elseif $value.is_invoice==2}
					是<sup style="font-size:10px;color:#999;">{if $value.is_invoiced==1}{elseif $value.is_invoiced==2}√{/if}</sup>
					{/if}
				</td>
				<td class="td-status">
					{if $value.state==1}
					待付款
					{elseif $value.state==2}
					待发货
					{elseif $value.state==3}
					待收货
					{elseif $value.state==4}
					已完成(待评价)
					{elseif $value.state==5}
					退款/售后
					{elseif $value.state==6}
					取消付款
					{/if}
				</td>
				<td>{:date('Y-m-d H:i:s',$value.time)}</td>
				<td class="td-manage">
					<a title="删除" href="javascript:;" onclick="admin_del(this,{$value.id})" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
				</td>
			</tr>
      		{/foreach}
		    <tr>
		        <td colspan="15">
			        <div class="pagelist"  style="text-align: right;">
			        	{$list->render()|raw}
			        </div>
		        </td>
		    </tr>
		</tbody>
	</table>
</div>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="/static/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="/static/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
function export_order() {
	$.ajax({
		type: 'POST',
		url: 'export_order',
		data:{},
		success: function(data){
		},
		error:function(data) {
		},
	});
}
function admin_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: 'order_del',
			data:{id:id},
			success: function(data){
				$(obj).parents("tr").remove();
				layer.msg('已删除!',{icon:1,time:3000});
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}
function order_detail(title,url,id,w,h){
	layer_show(title,url,w,h);
}
$(".pagelist").on("click",".pagination a",function(){
  var url=$(this).attr("href");
  var fromtime=$("#datemin").val();
  var totime=$("input[name=totime]").val();
  var state=$("#selecttmd").val();
  var pay_style=$("#pay_style").val();
  var keyword=$("#keyword").val();
  url=url+'&fromtime='+fromtime+'&totime='+totime+'&keyword='+keyword+'&state='+state+'&pay_style='+pay_style;
  getPage(url);
  return false;
});
function getPage(url)
{
  $.get(url, function(data){
    $("body").html(data);
  });
}
</script>
{/block}